/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package za.co.ray.jaxwsspring;

import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;

/**
 *
 * @author Coetzeer
 */
public class Client {

    private String URL = "";

    public Client(String URL) {
        this.URL = URL;
    }

    public Employee useServiceToGetEmployee(String guid) {
        JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();

        factory.getInInterceptors().add(new LoggingInInterceptor());
        factory.getOutInterceptors().add(new LoggingOutInterceptor());
        factory.setServiceClass(AuthService.class);
        factory.setAddress(URL);
        AuthService xclient = (AuthService) factory.create();

        Employee employee = xclient.getEmployee(guid);
        return employee;
    }

    public static void main(String args[]) throws Exception {

        Client c = new Client("http://localhost:7001/authManager/services/cxfAuth");
        Employee employee = c.useServiceToGetEmployee("0223938");
        System.out.println("Server said: " + employee.getLastName() + ", " + employee.getFirstName());
        System.exit(0);

    }
}
